package logic;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.UnknownHostException;



public class Sender {
	private static Integer PORT = 53;
	
	private InetAddress getDNSServerIP() throws UnknownHostException{
		InetAddress addr=InetAddress.getByName("194.186.60.107");
		return addr;
	}

	
	public byte[] Send(byte[] forSend) throws IOException  {	
		byte[] result = new byte[512];
		DatagramPacket packetForSend= new DatagramPacket(forSend, forSend.length, getDNSServerIP(), PORT);
		DatagramPacket packetForReturn=new DatagramPacket(result, result.length, getDNSServerIP(), PORT);
		DatagramSocket socket= new DatagramSocket();
		socket.send(packetForSend);		
		socket.receive(packetForReturn);		
		socket.close();
		return result;
	}
}
